package artifact

import "fmt"

type MainStat struct {
	Main [5]StatWords
}

func PickMainStatWords(aktUseful bool, hpUseful bool, defenseUseful bool, masteryUseful bool, rechargeUseful bool) []MainStat {
	var at []MainStat
	var flowerAndPlume [5]StatWords
	flowerAndPlume[0] = getNormalFlower()
	flowerAndPlume[1] = getNormalPlume()
	sands := getNormalEon(aktUseful, hpUseful, defenseUseful, masteryUseful, rechargeUseful)
	eon := getNormalGoblet(aktUseful, hpUseful, defenseUseful, masteryUseful)
	crown := getNormalCirclet(aktUseful, hpUseful, defenseUseful, masteryUseful)

	for _, i := range sands {
		for _, j := range eon {
			for _, k := range crown {
				temp := flowerAndPlume
				temp[2] = i
				temp[3] = j
				temp[4] = k
				at = append(at, MainStat{
					temp,
				})
			}
		}
	}
	return at
}

type SubGroup struct {
	Rate     float64
	Dmg      float64
	Atk      float64
	Hp       float64
	Defense  float64
	Mastery  float64
	Recharge float64
}

var AllPossibleCombinations [736281]SubGroup

func init() {
	fmt.Println("初始化副词条组合数组")
	AllPossibleCombinations = getAllPossibleCombinations()
}
func PickSubStat25Words(aktUseful bool, hpUseful bool, defenseUseful bool, masteryUseful bool, rechargeUseful bool) []SubStatWord {
	var allGroup []SubStatWord

	for _, group := range AllPossibleCombinations {

		if !aktUseful && group.Atk != 0 {
			continue
		}
		if !hpUseful && group.Hp != 0 {
			continue
		}
		if !defenseUseful && group.Defense != 0 {
			continue
		}
		if !masteryUseful && group.Mastery != 0 {
			continue
		}
		if !rechargeUseful && group.Recharge != 0 {
			continue
		}

		allGroup = append(allGroup, initSubStatWord(group))
	}
	return allGroup
}

func getAllPossibleCombinations() [736281]SubGroup {
	max := 25
	var allGroup [736281]SubGroup
	var index = 0
	for rate := 0; rate <= max; rate++ {
		for dmg := 0; dmg <= max-rate; dmg++ {
			for atk := 0; atk <= max-rate-dmg; atk++ {
				for hp := 0; hp <= max-rate-dmg-atk; hp++ {
					for defense := 0; defense <= max-rate-dmg-atk-hp; defense++ {
						for mastery := 0; mastery <= max-rate-dmg-atk-hp-defense; mastery++ {
							allGroup[index] = SubGroup{
								Rate:     float64(rate),
								Dmg:      float64(dmg),
								Atk:      float64(atk),
								Hp:       float64(hp),
								Defense:  float64(defense),
								Mastery:  float64(mastery),
								Recharge: float64(max - rate - dmg - atk - hp - defense - mastery)}
							index++
						}
					}
				}
			}
		}
	}
	return allGroup
}
